home *** CD-ROM | disk | FTP | other *** search
- // Kustom Magic Software, Copyright (c) 1995, Ralph Krausse
- // File Created on 1/7/96 11:02:00 AM
-
- #include <windows.h>
- #include "winexample.h"
-
- HINSTANCE hInst;
-
- APPINFO gAppInfo;
- WINEXAMPLE WinExample;
-
- int PASCAL WinMain(HINSTANCE hinstCurrent, HINSTANCE hinstPrevious, LPSTR lpszCmdLine, int nCmdShow)
- {
- MSG msg;
- if (!hinstPrevious)
- if (!InitApplication(hinstCurrent))
- return FALSE;
-
- if (!InitInstance(hinstCurrent, nCmdShow))
- return FALSE;
-
- if (!InitValidation())
- return FALSE;
-
- while (GetMessage(&msg,NULL,NULL,NULL))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return (msg.wParam);
- }
-
- BOOL InitValidation(void)
- {
- char szPath[_MAX_PATH];
- int wErr = 0,wSealLen = 0;
-
- gAppInfo.bOverWriteSeal = 0;
- strcpy(gAppInfo.szMagicString,"demomagicstring");
-
- getcwd(szPath,100);
- strcat(szPath,"\\winexample.exe");
- strcpy(gAppInfo.szAppName,szPath);
-
- wSealLen = sizeof(WINEXAMPLE);
- if(wErr = ValidateApplication(&gAppInfo, wSealLen, &WinExample))
- {
- if(wErr)
- {
- char szErrorString[250], szDisplayString[350];
- GetSealError (wErr, szErrorString);
- wsprintf(szDisplayString,"Error %d, %s",wErr,szErrorString);
- MessageBox(NULL,szDisplayString,"Validation Error",MB_ICONSTOP);
- return(FALSE);
- }
- }
- return(TRUE);
- }
-
- BOOL InitApplication(HINSTANCE hinstCurrent)
- {
- WNDCLASS wc;
- wc.style = NULL;
- wc.lpfnWndProc = MainWndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hinstCurrent;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = GetStockObject(WHITE_BRUSH);
- wc.lpszMenuName = "WINEXAMPLEMenu";
- wc.lpszClassName = "WINEXAMPLEClass";
- return (RegisterClass(&wc));
- }
-
- BOOL InitInstance(HINSTANCE hinstCurrent, int nCmdShow)
- {
-
- HWND hWnd;
- hInst = hinstCurrent;
- hWnd = CreateWindow("WINEXAMPLEClass","WinExample Sample Application", WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
- NULL,NULL,hinstCurrent,NULL );
- if (hWnd == NULL)
- return FALSE;
- ShowWindow(hWnd, nCmdShow);
- UpdateWindow(hWnd);
- return TRUE;
- }
-
- LRESULT FAR PASCAL MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- FARPROC lpProcAbout;
- switch (message)
- {
- case WM_COMMAND:
- if (wParam == IDM_ABOUT)
- {
- lpProcAbout = MakeProcInstance((FARPROC) About, hInst);
- DialogBox(hInst,"AboutBox",hWnd,(DLGPROC) lpProcAbout);
- FreeProcInstance(lpProcAbout);
- break;
- }
- else if(wParam == IDM_SHOWINFO)
- {
- char szBuffer[100];
- wsprintf(szBuffer,"Magic String: %s",gAppInfo.szMagicString);
- MessageBox(hWnd,szBuffer,"Validation Info",MB_ICONINFORMATION);
- break;
- }
- else
- return (DefWindowProc(hWnd, message, wParam, lParam));
-
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
-
- default:
- return (DefWindowProc(hWnd, message, wParam, lParam));
- }
- return NULL;
- }
-
- BOOL FAR PASCAL About(HWND hDlg, WORD message, WPARAM wParam, LPARAM lParam)
- {
- switch (message)
- {
- case WM_COMMAND:
- if (wParam == IDOK || wParam == IDCANCEL)
- {
- EndDialog(hDlg, TRUE);
- return TRUE;
- }
- break;
- }
- return FALSE;
- }
-
-
-